package com.example.getwifiip.utils

import android.app.AlertDialog
import android.content.Context
import android.text.TextUtils

import com.yanzhenjie.permission.Rationale
import com.yanzhenjie.permission.RequestExecutor
import com.yanzhenjie.permission.runtime.Permission


class RuntimeRationale : Rationale<List<String>> {

    override fun showRationale(
        context: Context,
        permissions: List<String>,
        executor: RequestExecutor
    ) {
        val permissionNames = Permission.transformText(context, permissions)
        val message = TextUtils.join("\n", permissionNames)

        AlertDialog.Builder(context).setCancelable(false)
            .setTitle("提示")
            .setMessage(message)
            .setPositiveButton("确定") { _, _ -> executor.execute() }
            .setNegativeButton("取消") { _, _ -> executor.cancel() }
            .show()
    }
}